/**
 * Author(s): xuming.Wong <xuming.Wong@gmail.com>
 */

#ifndef __NG_UTIL_H__
#define __NG_UTIL_H__

#include "OgreString.h"
#include "OgreStringVector.h"

namespace PQEngine
{
	/* class used to check path string
	*/
	class GPath
	{
	public:
		static const Ogre::String SEPERATOR;
	public:
		inline static std::string getExt(std::string line)
		{
			int pos=line.find_last_of(".");
			if(pos=line.npos){
				return "";
			}
			std::string ext=line.substr(pos+1);
			return ext;
		}
		GPath();
		GPath(const Ogre::String& file);
		GPath(const char* file);
		~GPath();
		const Ogre::String& getPath(void) const;
		Ogre::String getAbsPath(void) const;

		// file access
		void getAsString(Ogre::String &dest) const;
		Ogre::String getAsString(void) const;
		Ogre::String directory(void) const;
		Ogre::String base(void) const;
		Ogre::String extension(void) const;

		// seperator '/'
		void	normalize(void) const;

		/// normalize based on platform seperator
		void	normalizePlatform(void) const;

		int getFileSize(void) const;
		void	append(const Ogre::String &v);

		bool isAbs(void) const;
		bool isRel(void) const;

		bool exists(void) const;
		bool isFile(void) const;
		bool isDir(void) const;

		void split(Ogre::StringVector &arr) const;
	protected:
		mutable Ogre::String _path;
	};

	class NgUtil
	{
	public:
		static bool isResource(const Ogre::String &name, const Ogre::String &group=Ogre::StringUtil::BLANK);
		static Ogre::ColourValue getInterpolatedColor(float fx, float fy, Ogre::Image *img, bool wrapX);
	};


}
#endif
